<?php

function smarty_function_order($params, &$smarty) {
	$request = Zend_Controller_Front::getInstance()->getRequest();
	$view = $smarty->getTemplateVars('this');
	$name = isset($params['name']) ? $params['name'] : 'title';
	$title = isset($params['title']) ? $params['title'] : 'title';
	$value = isset($params['value']) ? $params['value'] : $view->order;
	$class = 'order';
	if ($value == $name)
	{
		$name .= ' desc';
		$class .= ' asc';
	}
	elseif ($value == $name.' desc')
	{
		$class .= ' desc';
	}
	$href = $view->url(array('order' => $name));
	return '<a href="'.$href.'" class="'.$class.'">'.$title.'</a>';
}
